package com.ftg.learn.privilege.util;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 类名随意，见名知意
 * swaggerconfig
 * 注解
 * @Configuration
 *  把当前javabean做为配置类来使用
 *    xml
 * @EnableSwagger2
 *  表示当前工程开始swagger2功能
 * @author KangJx
 * @date 2021/5/31
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    /**
     * @bean 把当前方法返回值，注入到spring容器里面
     * @return
     */
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any()).build();
    }

    /**
     * 这是一个方法，api application interface
     * info information 信息
     * @return
     */
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("齐大实训")
                .description("针对齐大，实训做知识讲解，以及项目研发使用")
                .version("1.0.0")
                .build();
    }

}
